Visual Basic for Applications Reference

Input Function

See Also    Example    Specifics

Returns String containing characters from a file opened in Input or Binary mode.

Syntax

Input(number, [#]filenumber)

The Input function syntax has these parts:

Part Description
number Required. Any valid numeric expression specifying the number of characters to return.
filenumber Required. Any valid file number.

Remarks

Data read with the Input function is usually written to a file with Print # or Put. Use this function only with files opened in Input or Binary mode.

Unlike the Input # statement, the Input function returns all of the characters it reads, including commas, carriage returns, linefeeds, quotation marks, and leading spaces.

With files opened for Binary access, an attempt to read through the file using the Input function until EOF returns True generates an error. Use the LOF and Loc functions instead of EOF when reading binary files with Input, or use Get when using the EOF function.

Security Note   When reading from files, do not make decisions about the contents of the file based on the file name extension. For example, a file named Form1.vb may not be a Visual Basic source file.

Note   Use the InputB function for byte data contained within text files. With InputB, number specifies the number of bytes to return rather than the number of characters to return.